<html><head><title>component.html.utils.template.Parser</title><link rel="stylesheet" type="text/css" href="../../../../../styles/main.css"><link rel="stylesheet" type="text/css" href="../../../../../styles/prettify.css"><script language=JavaScript src="../../../../../javascript/prettify.js"></script><script language=JavaScript src="../../../../../javascript/main.js"></script></head><body class="FramedContentPage" onLoad="{NDOnLoad();prettyPrint();}"><script language=JavaScript><!--
if (browserType) {document.write("<div class=" + browserType + ">");if (browserVer) {document.write("<div class=" + browserVer + ">"); }}// --></script>

<!--  Generated by Natural Docs, version 1.4 -->
<!--  http://www.naturaldocs.org  -->

<!-- saved from url=(0026)http://www.naturaldocs.org -->




<div id=Content><div class="CClass"><div class=CTopic id=MainTopic><h1 class=CTitle><a name="component.html.utils.template.Parser"></a>component.<wbr>html.<wbr>utils.<wbr>template.<wbr>Parser</h1><div class=CBody><p>Utility class resposible for parsing string value and replacing any {{placeholder}} variables with those defined in handlerInstance.</p><p>In addition this parser also replaces any {{event:callBackname}} with {window[&lsquo;eventManagerName&rsquo;].handleOnClick(&lsquo;callBackname&rsquo;, &lsquo;handlerName&rsquo;)} javascript, so the handler can recieve the event been parsed as function invoke.</p><h4 class=CHeading>usage</h4><blockquote><pre class="prettyprint">var handlerInstance = {
    temp1 : &quot;MyValue&quot;,
    getId : function() {
        return 'myId';
    },
    onClick : function() {
        // ... do something on click ..
    }
}

var tempalteValueString = &quot;tempalate {{temp1}} is replaced. and {{event:onClick}} too.&quot;;

var parser = new component.html.utils.template.Parser(domEventManagerInstance);
var v = parser.parse(templateValueString, handlerInstance);

// v == 'template MyValue is replaced. and {window['eventManagerName'].handleOnCLick('onClick', 'myId')} too.'</pre></blockquote><h4 class=CHeading>usage notes</h4><ul><li>The handlerInstance should be registered within <a href="../../../../api/system/DomEventManager-js.html#api.system.DomEventManager" class=LClass id=link2 onMouseOver="ShowTip(event, 'tt2', 'link2')" onMouseOut="HideTip('tt2')">api.system.DomEventManager</a> to be able to handle the dispatched events.</li><li>The handlerInstance should provide getId function within its prototype returning unique ID, so that the dispatcher can map to it.&nbsp; Actually <a href="../../../../api/system/DomEventManager-js.html#api.system.DomEventManager" class=LClass id=link3 onMouseOver="ShowTip(event, 'tt2', 'link3')" onMouseOut="HideTip('tt2')">api.system.DomEventManager</a> uses getId function to register given handlerInstance too.</li></ul><!--START_ND_SUMMARY--><div class=Summary><div class=STitle>Summary</div><div class=SBorder><table border=0 cellspacing=0 cellpadding=0 class=STable><tr class="SMain"><td class=SEntry><a href="#component.html.utils.template.Parser" >component.<wbr>html.<wbr>utils.<wbr>template.<wbr>Parser</a></td><td class=SDescription>Utility class resposible for parsing string value and replacing any {{placeholder}} variables with those defined in handlerInstance.</td></tr><tr class="SGroup SIndent1"><td class=SEntry><a href="#component.html.utils.template.Parser.Functions" >Functions</a></td><td class=SDescription></td></tr><tr class="SFunction SIndent2 SMarked"><td class=SEntry><a href="#component.html.utils.template.Parser.Template" >Template</a></td><td class=SDescription></td></tr><tr class="SFunction SIndent2"><td class=SEntry><a href="#component.html.utils.template.Parser.parse" id=link1 onMouseOver="ShowTip(event, 'tt1', 'link1')" onMouseOut="HideTip('tt1')">parse</a></td><td class=SDescription></td></tr></table></div></div><!--END_ND_SUMMARY--></div></div></div>

<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="component.html.utils.template.Parser.Functions"></a>Functions</h3></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="component.html.utils.template.Parser.Template"></a>Template</h3></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="component.html.utils.template.Parser.parse"></a>parse</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>parse : function(</td><td class=PParameter nowrap>value,</td></tr><tr><td></td><td class=PParameter nowrap>handler</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote></div></div></div>

</div><!--Content-->



<!--START_ND_TOOLTIPS-->
<div class=CToolTip id="tt1"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>parse : function(</td><td class=PParameter nowrap>value,</td></tr><tr><td></td><td class=PParameter nowrap>handler</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote></div></div><div class=CToolTip id="tt2"><div class=CClass>System object resposible to handle events from registered targets. </div></div><!--END_ND_TOOLTIPS-->

<script language=JavaScript><!--
if (browserType) {if (browserVer) {document.write("</div>"); }document.write("</div>");}// --></script></body></html>